package com.start.workflow.core.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.start.common.api.Result;
import com.start.common.dataRule.DataQueryConstructor;
import com.start.common.mybaitsplus.StartMBColumnTools;
import com.start.workflow.core.manage.StartActModelManage;
import com.start.workflow.model.StartProcessModel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "流程模型类别API")
@RequestMapping("/startActModelApi")
public class StartActModelApi {

    @Autowired
    private StartActModelManage startActModelManage;

    @Operation(summary = "获取可用的流程模型")
    @GetMapping("/pageDeployActModel")
    public Result<?> pageDeployActModel(Page<StartProcessModel> page) {
        QueryWrapper<StartProcessModel> entity = DataQueryConstructor.createEntity(StartProcessModel.class);
        entity.ge(StartMBColumnTools.getColumn(StartProcessModel::getDeployVersion), 0);
        return Result.ok(startActModelManage.pageModel(page, entity));
    }

    @Operation(summary = "获取可用的流程模型")
    @GetMapping("/getListActModel")
    public Result<?> getListActModel() {
        return Result.ok(startActModelManage.getGroupModels());
    }
}
